package com.larry.etl;

/**
 * @ProjectName hadoop
 * @Author larry
 * @Date 14:03 2021/11/25
 * @Description 数据清洗
 **/
public class ETLUtil {
    public static String etl(String line){

        StringBuffer sb = new StringBuffer();

        String[] split = line.split("\t");

        if (split.length < 9){
            return null;
        }
        split[3] = split[3].replaceAll(" ","");

        for (int i = 0; i < split.length; i++) {
            if (i <= 8){
                if (i == split.length - 1){
                    sb.append(split[i]);
                }else {
                    sb.append(split[i]).append("\t");
                }
            }else {
                if (i == split.length - 1){
                    sb.append(split[i]);
                }else {
                    sb.append(split[i]).append("&");
                }
            }
        }

        return sb.toString();
    }
}
